home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
PROGIALS
/
PTUTOR2B.LZH
/
SUBRANGE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-01-15
|
2KB
|
44 lines
(* Chapter 8 - Program 2 *)
program Scaler_Operations;
type Days = (Mon,Tue,Wed,Thu,Fri,Sat,Sun);
Work = Mon..Fri;
Rest = Sat..Sun;
var Day : Days; (* This is any day of the week *)
Workday : Work; (* These are the the working days *)
Weekend : Rest; (* The two weekend days only *)
Index : 1..12;
Alphabet : 'a'..'z';
Start : 'a'..'e';
begin (* main program *)
(* The following statements are commented out because they contain
various errors that will halt compilation.
Workday := Sat; Sat is not part of Workday's subrange.
Rest := Fri; Fri is not part of Weekend's subrange.
Index := 13; Index is only allowed to go up to 12,
Index := -1; and down to 1.
Alphabet := 'A' Alphabet, as defined, includes only the
lower case alphabet.
Start := 'h' h is not in the first five letters.
End of commented out section. *)
Workday := Tue;
Weekend := Sat;
Day := Workday;
Day := Weekend;
Index := 3+2*2;
Start := 'd';
Alphabet := Start;
(* since Alphabet is "d" *)
Start := Succ(Alphabet); (* Start will be 'e' *)
Start := Pred(Alphabet); (* Start will be 'c' *)
Day := Wed;
Day := Succ(Day); (* Day will now be 'Thu' *)
Day := Succ(Day); (* Day will now be 'Fri' *)
Index := Ord(Day); (* Index will be 4 (Fri = 4) *)
end. (* of main program *)